<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <form action="writeFile2.php" method="post">
    请发表你的评论：<br>
    <textarea id="subject" name="subject"></textarea><br>
    <button name="submit">提交</button>
  </form>

  <?php
  //判断是否提交
  if (isset($_POST["submit"])) {
    $content = $_POST["subject"];
    $path = "./uploads/test.txt";

    $result = file_put_contents($path, $content);
    if ($result) {
      echo "文件写入成功！";
    } else {
      echo "文件写入失败";
    }
  }

  ?>
</body>

</html>